home *** CD-ROM | disk | FTP | other *** search
- ;; File: ControlKeyPatch.a
- ;;
- ;; Description:
- ;; routines for patching the ADB manager to simulate the control
- ;; key being held down. This file contains the 68000 code for
- ;; the patch resource.
- ;;
- ;; Author: John Montbriand
- ;;
- ;; Copyright:
- ;; Copyright © 1999 by Apple Computer, Inc.
- ;; All rights reserved worldwide.
- ;;
- ;; Disclaimer:
- ;; You may incorporate this sample code into your applications without
- ;; restriction, though the sample code has been provided "AS IS" and the
- ;; responsibility for its operation is 100% yours. However, what you are
- ;; not permitted to do is to redistribute the source as "DSC Sample Code"
- ;; after having made changes. If you're going to re-distribute the source,
- ;; we require that you make it clear in the source that the code was
- ;; descended from Apple Sample Code, but that you've made changes.
- ;;
- ;; Change History (most recent first):
- ;; 27/8/99 created by John Montbriand
-
- case on
- include 'Types.a'
-
- ADBPatchResource main
-
- bra.s ADBPatch(PC)
- bra.s SetDown(PC)
- bra.s SetUp(PC)
-
- command EQU 0 ; key down command
- downflag EQU 4 ; flag for tracking key
- originaljump EQU 8 ; original service routine
- originaldata EQU 12 ; original service routine's data
-
- controldown:
- dc.l $0236FF00
-
- controlup:
- dc.l $02B6FF00
-
- SetDown:
- movea.l 4(SP), A2
- cmpi.l #1, downflag(A2) ;; test to see if the key is already down
- beq.s @1
- ;; set the down flag to true
- move.l #1, downflag(A2)
- ;; jump to the original service routine
- move.l command(A2), D0
- lea controldown(PC), A0
- movea.l #0, A1
- move.l originaljump(A2), -(SP)
- movea.l originaldata(A2), A2
- rts
-
- @1:
- rts
-
- SetUp:
- movea.l 4(SP), A2
- cmpi.l #0, downflag(A2) ;; test to see if the key is already up
- beq.s @1
- ;; set the down flag to false
- move.l #0, downflag(A2)
- ;; jump to the original service routine
- move.l command(A2), D0
- lea controlup(PC), A0
- movea.l #0, A1
- move.l originaljump(A2), -(SP)
- movea.l originaldata(A2), A2
- rts
-
- @1:
- rts
-
- ADBPatch:
- ;; R0?
- btst #0, D0
- bne.s @1
- btst #1, D0
- bne.s @1
- ;; talk?
- btst #2, D0
- beq.s @1
- btst #3, D0
- beq.s @1
- ;; test to see if the key is locked down
- cmpi.l #1, downflag(A2) ;; test to see if the key is down
- bne.s @1
- ;; block key downs
- cmpi.b #$02, 0(A0)
- bne.s @2
- cmpi.b #$36, 1(A0)
- bne.s @2
- cmpi.b #$FF, 2(A0)
- bne.s @2
- rts
- @2: ;; block key ups
- cmpi.b #$02, 0(A0)
- bne.s @1
- cmpi.b #$B6, 1(A0)
- bne.s @1
- cmpi.b #$FF, 2(A0)
- bne.s @1
- rts
- @1: ;; jump through to the original routine
- move.l originaljump(A2), -(SP)
- movea.l originaldata(A2), A2
- rts
-
- endmain
-
- end
-